﻿using DocumentFormat.OpenXml.Lite.Helper;
using DocumentFormat.OpenXml.Lite.SpreadsheetML.Excel.Types;
using DocumentFormat.OpenXml.Lite.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace DocumentFormat.OpenXml.Lite.SpreadsheetML.Excel.WorksheetElements
{
    [XmlRoot("f", Namespace = Constants.ExcelMain)]
    public class Formula : XmlSerializable
    {
        #region Attributes

        [Optional]
        [XmlAttribute("t")]
        public Nullable<ST_CellFormulaType> FormulaType { get; set; }

        [Optional]
        [XmlAttribute("aca", Form = XmlSchemaForm.Qualified)]
        public Nullable<bool> AlwaysCalculateArray { get; set; }

        [Optional]
        [XmlAttribute("ref", Form = XmlSchemaForm.Qualified)]
        public string RangeOfCells { get; set; }

        [Optional]
        [XmlAttribute("dt2D", Form = XmlSchemaForm.Qualified)]
        public Nullable<bool> Datatable2D { get; set; }

        [Optional]
        [XmlAttribute("dtr", Form = XmlSchemaForm.Qualified)]
        public Nullable<bool> DatatableRow { get; set; }

        [Optional]
        [XmlAttribute("del1", Form = XmlSchemaForm.Qualified)]
        public Nullable<bool> Input1Deleted { get; set; }

        [Optional]
        [XmlAttribute("del2", Form = XmlSchemaForm.Qualified)]
        public Nullable<bool> Input2Deleted { get; set; }

        [Optional]
        [XmlAttribute("r1", Form = XmlSchemaForm.Qualified)]
        public string DatatableCell1 { get; set; }

        [Optional]
        [XmlAttribute("r2", Form = XmlSchemaForm.Qualified)]
        public string InputeCell2 { get; set; }

        [Optional]
        [XmlAttribute("ca", Form = XmlSchemaForm.Qualified)]
        public Nullable<bool> CalculateCell { get; set; }

        [Optional]
        [XmlAttribute("si", Form = XmlSchemaForm.Qualified)]
        public Nullable<uint> SharedGroupIndex { get; set; }

        [Optional]
        [XmlAttribute("bx", Form = XmlSchemaForm.Qualified)]
        public Nullable<bool> AssingsValueToName { get; set; }

        #endregion

        [XmlText]
        public string Value { get; set; }

        public Formula() { }
    }
}
